package cn.player.entity;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONObject;

import cn.player.media.util.ParseUtil;


/**
 * 频道导航
 * 	频道分类
 * 		央视频道、卫视频道、地方频道...
 * 	搜索方式
 * 		按名称 按热度 节目单
 * 		央视频道、卫视频道、地方频道...
 * @author zengliang
 *
 */
public class ChannelNav {
	private String title;
	private String identify;
	private String listUrl;
	private String order;
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	
	public String getIdentify() {
		return identify;
	}
	public void setIdentify(String identify) {
		this.identify = identify;
	}
	public String getListUrl() {
		return listUrl;
	}
	public void setListUrl(String listUrl) {
		this.listUrl = listUrl;
	}
	public String getOrder() {
		return order;
	}
	public void setOrder(String order) {
		this.order = order;
	}
	
	/**
	 * 获取频道分类列表
	 * test url ="http://serv.cbox.cntv.cn/json/zhibo/pindaodaohang/index.json"
	 * @param obj
	 * @return
	 */
	public static List<ChannelNav> getCategoryList(JSONObject obj){
		List<ChannelNav> cCategories = new ArrayList<ChannelNav>();
		JSONObject data = obj.optJSONObject("data");
		try {
			cCategories.add(ParseUtil.parseDataToEntity(data, "default", ChannelNav.class));
			cCategories.addAll(ParseUtil.parseDataToCollection(data, "categoryList", ChannelNav.class));
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		
		return cCategories.size() == 0 ? null : cCategories;
	}
	
	/**
	 * 获取order列表
	 * test url ="http://serv.cbox.cntv.cn/json/zhibo/pindaodaohang/index.json"
	 * @param obj
	 * @return
	 */
	public static List<ChannelNav> getOrderList(JSONObject obj){
		List<ChannelNav> orderList = null;
		JSONObject data = obj.optJSONObject("data");
		try {
			orderList = ParseUtil.parseDataToCollection(data, "orderList", ChannelNav.class);
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		return orderList;
	}

}
